#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a_[N],c[N];
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int n,m,t;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a_[i]);
    for(int i=1;i<=m;i++)
        scanf("%d",&c[i]);
    int k=ceil(log2(n));
    for(int i=1;i<=k;i++){
        string s;
        cin>>s;
    }
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
        printf("%d\n",(rand()^rand())%(n*m));
    return 0;
}
